package com.telecomyt.jwportal.utils;

import java.io.Closeable;

import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @author created by chengDa
 * @time 2020/8/26  16:42
 * @description
 */
public class RxUtils {
    /**
     * 关闭流
     *
     * @param c 需要关闭的流
     */
    public static void close(Closeable c) {
        if (c == null) return;
        try {
            c.close();
        } catch (Throwable t) {
            // do nothing
        }
    }


    public static  <T> ObservableTransformer<T, T> setThread() {
        return upstream -> upstream.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }
}
